<?php

namespace App\Http\Requests\Business;

use Illuminate\Foundation\Http\FormRequest;

class InvoiceTargetKeyProductRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'year' => 'required|numeric',
            'sales_region_code' => 'exists:sales_region,code',
            'category_key_product_id' => 'exists:category_key_product,id',
            'quantity' => 'required|numeric',
        ];
        switch (request()->method) {
            case 'POST':
                break;
            case 'PUT':
                break;
            default:
                break;
        }

        return $rules;
    }

    public function messages()
    {
        return [
            'year.numeric' => '请选择年份！',
            'sales_region_code.exists' => '请选择销售大区',
            'category_key_product_id.exists' => '请选择重点产品分类',
            'quantity.required' => '请输入指标！',
            'quantity.numeric' => '指标为数字格式！',
        ];
    }
}
